#!/bin/bash
#

SERVER="http://localhost"
export PATH=/bin:/sbin:/usr/bin:/usr/local/bin

curl $SERVER/status/api/v1/update_desc \
	-d "path=rand" -d "unit=num" -d "low=0&high=100" 2&>/dev/null

INDEX=0
AddRecord(){
	curl $SERVER/status/api/v1/add -d "path=$1&value=$2" 2&>/dev/null
}

vmstat "$@" |
	while read proc b swap free buff cache si so bi bo sysin syscs us sy id wa
	do
		INDEX=$((INDEX+1))
		[[ $INDEX -le 2 ]] && continue
		NUM=$((RANDOM%50))
		AddRecord rand $NUM
		AddRecord local/cpu-idle $id
		AddRecord local/cpu-sys $sy
		echo "Upload ssar DONE"
	done
